﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Collisions;
using Microsoft.Xna.Framework.Graphics;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Factories;

namespace XNA_2DFramwork
{
    public class Circle:VisualObject
    {
       
        private Vector2 _origin;
        private int _Radius;
      
        public Color Color;

        public Circle(Game Game, int radius, Vector2 position, Color color, GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator)
            : base(Game)
        {
            _Radius = radius;
            Color = color;
            Position = position;
            
            Texture = DemoBaseXNA.DrawingSystem.DrawingHelper.CreateCircleTexture(graphicsDevice, _Radius, Color);
            _origin = new Vector2(Texture.Width/2f, Texture.Height/2f);
            Body = BodyFactory.Instance.CreateCircleBody(physicsSimulator, _Radius, 0.5f);
            Body.Position= position;
            Geom = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, Body, _Radius, 10);
            //Geom.CollisionResponseEnabled = false;
            SpriteBatch = new SpriteBatch(graphicsDevice);
        }
        public override void Draw()
        {
            SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            SpriteBatch.Draw(Texture, Geom.Position, null, Color, Body.Rotation, _origin, 1f, SpriteEffects.None, 0f);
            SpriteBatch.End();
            
        }

        public override void Update()
        {
             
        }

    }
}
